const babel = require('rollup-plugin-babel');
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const postcss = require('rollup-plugin-postcss');
const autoprefixer  = require('autoprefixer');
const cssnano = require('cssnano');
const uglify = require('rollup-plugin-uglify');

module.exports = {
    input: "src/main.js",
    output: {
        name: "LoadMore",
        file: 'dist/main.js',
        format: 'iife'
    },
    plugins: [
        // 打包外部文件
        resolve({
            jsnext: true, // 该属性是指定将Node包转换为ES2015模块
            // main 和 browser 属性将使插件决定将那些文件应用到bundle中
            main: true, // Default: true 
            browser: true // Default: false
        }),
        commonjs(), // 转换 commonjs 规范
        postcss({
            extensions: ['.css', '.less'],
            plugins: [
                autoprefixer(), 
                // cssnano()
            ],
            // extract: 'dist/css/bundle.css' // 输出路径
        }),
        babel({
            runtimeHelpers: "true",
            exclude: 'node_modules/**' // 排除node_module下的所有文件
        }),
        uglify.uglify() // 压缩代码
    ],
    external: ['jquery'] // 不打包jquery代码带自己的代码中去
}